package com.siqi.hr.system.organization.entity;

import java.sql.ResultSet;
import java.sql.SQLException;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

import org.springframework.jdbc.core.RowMapper;

/**
 * 角色对象实体
 * @author    xiaogq
 */
@Entity
@Table(name = "t_1")
public class Role {
	private static final long serialVersionUID = -6262319599841170155L;

	/**
	 * 角色id
	 */
	@Column(name = "id")
	private String id;

	/**
	 * 角色名称
	 */
	@Column(name = "name_varchar")
	private String name;

	/**
	 * 是否管理员
	 */
	@Column(name = "isadmin_bit")
	private Boolean isAdmin;

	/**
	 * 描述
	 */
	@Column(name = "description_varchar")
	private String description;

	/**
	 * 可登陆模块
	 */
	@Column(name = "loginModule_varchar")
	private String loginModule;

	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getKeyText() {
		return null;
	}

	public Role(String id) {
		this.id = id;
	}

	public Role() {
	}

	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getLoginModule() {
		return this.loginModule;
	}

	public void setLoginModule(String loginModule) {
		this.loginModule = loginModule;
	}

	public Boolean getIsAdmin() {
		return this.isAdmin;
	}

	public void setIsAdmin(Boolean isAdmin) {
		this.isAdmin = isAdmin;
	}

	public static class FullRecord extends Role implements RowMapper<Role> {
		public synchronized Role mapRow(ResultSet rs, int index) throws SQLException {
			Role role = new Role();
			role.setId(rs.getString("id"));
			role.setName(rs.getString("name_varchar"));
			role.setIsAdmin(Boolean.valueOf(rs.getBoolean("isadmin_bit")));
			role.setLoginModule(rs.getString("loginModule_varchar"));
			role.setDescription(rs.getString("description_varchar"));
			return role;
		}
	}

	@SuppressWarnings("serial")
	public static class mainRecord extends Role implements RowMapper<Role> {
		public synchronized Role mapRow(ResultSet rs, int index) throws SQLException {
			Role role = new Role();
			role.setId(rs.getString("id"));
			role.setName(rs.getString("name_varchar"));
			role.setDescription(rs.getString("description_varchar"));
			return role;
		}
	}
}
